<template>
    <div class="panel panel-default">
        <!--顶部-->
        <div class="panel-heading">
            <h3 class="panel-title text-left">收藏展示</h3>
        </div>
        <!--身体部分-->
        <div class="panel-body">
            <el-table
                    :data="tableData"
                    style="width: 100%">
                <el-table-column
                        label="创建日期">
                    <template slot-scope="scope">
                        <i class="el-icon-time"></i>
                        <span style="margin-left: 10px">{{scope.row.created_time|format}}</span>
                    </template>
                </el-table-column>
                <el-table-column
                        label="书名"
                        prop="book.name">
                </el-table-column>
                <el-table-column
                        label="作者"
                        prop="book.author_name">
                </el-table-column>
                <el-table-column align="right">

                    <template slot-scope="scope">
                        <el-button
                                size="mini"
                                type="danger"
                                @click="handleDelete(scope.$index, scope.row.id)">删除
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
        </div>
    </div>
</template>

<script>
    export default {
        name: "collectShowing",

        data() {
            return {
                tableData: [],
                user_id: '',
                show_id: []
            }
        },
        created() {
            this.show_book_coll()
        },
        methods: {
            //书籍展示删除
            handleDelete(index, row) {
                this.$axios.delete(`${this.$settings.base_url}/book/collectionshowdel/`, {params: {id: row}}).then(response => {

                    this.tableData = response.data;
                    this.show_book_coll()
                })

            },
            //书籍展示
            show_book_coll() {

                this.user_id = this.$cookies.get('user_dict').id;
                this.$axios.get(`${this.$settings.base_url}/book/collectionshow/`, {params: {user_id: this.user_id}}).then(response => {

                    this.tableData = response.data;
                    console.log(response.data.id)
                })
            }
        },
    }
</script>

<style scoped>

</style>